import {
  mutableHandles,
  readonlyHandles,
  shallowReadonlyHandles,
} from "./baseHandler";

export const enum ReactiveFlags {
  IS_REACTIVE = "__v_isReactive",
  IS_READONLY = "__v_isReadonly",
}
export function reactive(raw) {
  return createActiveObject(raw, mutableHandles);
}

export function readonly(raw) {
  return createActiveObject(raw, readonlyHandles);
}

export function shallowReadonly(raw) {
  return createActiveObject(raw, shallowReadonlyHandles);
}

function createActiveObject(raw, baseHandles) {
  return new Proxy(raw, baseHandles);
}

export function isReactive(value) {
  return !!value["__v_isReactive"];
}

export function isReadonly(value) {
  return !!value["__v_isReadonly"];
}

export function isProxy(value) {
  return isReactive(value) || isReadonly(value);
}
